package com.shopFund.contoller;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.shopFund.bean.UserFund;
import com.shopFund.service.IUserFundService;

import shopBean.common.bean.RestResult;
import shopBean.common.responseCode.Status;
import shopBean.common.utils.RestResultGenerator;

@RestController
@RequestMapping("/userFund/")
public class UserFundContoller {
	@Autowired
	IUserFundService userFundService;
	
	@RequestMapping("insert.api")
	public RestResult insert(@RequestBody UserFund userFund) {
		if(StringUtils.isBlank(userFund.getUserId())) {
			return RestResultGenerator.genErrorResult("用户id不能为空", null, Status.userId_is_empty);
		}
		if(userFund.getMoney() == null) {
			return RestResultGenerator.genErrorResult("金额不能为空", null, Status.money_is_empty);
		}
		if(userFund.getScore() == null) {
			return RestResultGenerator.genErrorResult("积分不能为空", null, Status.score_is_empty);
		}
		return RestResultGenerator.genSuccessResult(this.userFundService.insert(userFund));
	}
}
